<article id="wikiArticle">
<div> <div class="blockIndicator obsolete obsoleteHeader"><p><strong><span class="icon-only-inline" title="This is an obsolete API and is no longer guaranteed to work."><i class="icon-trash"> </i></span> 已废弃 Gecko 33 (Firefox 33 / Thunderbird 33 / SeaMonkey 2.30)</strong><br/>This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.</p></div> <div class="blockIndicator nonStandard nonStandardHeader">
<p><strong><span class="icon-only-inline" title="This API has not been standardized."><i class="icon-warning-sign"> </i></span> 非标准</strong><br/>
      该特性是非标准的，请尽量不要在生产环境中使用它！</p>
</div></div>
<h2 id="Summary" name="Summary">概览</h2>
<p><strong><code>Number.toInteger()</code></strong> 用来将参数转换成整数,但该方法的实现已被移除.</p>
<p>如果参数是 <a href="Reference/Global_Objects/NaN" title="全局属性 NaN 的值表示不是一个数字（Not-A-Number）。"><code>NaN</code></a>, <a href="Reference/Global_Objects/null" title="值 null 特指对象的值未设置。它是 JavaScript 基本类型 之一。"><code>null</code></a> 或 <a href="Reference/Global_Objects/undefined" title="undefined是全局对象的一个属性。也就是说，它是全局作用域的一个变量。undefined的最初值就是原始数据类型undefined。"><code>undefined</code></a>, 会返回0 . 如果参数值是true返回1,false的话返回<span style="line-height: 19.0909080505371px;">0</span>.</p>
<h2 id="Syntax" name="Syntax">语法</h2>
<pre><code class="language-javascript"><code>Number.toInteger(<var>number</var>)</code></code></pre>
<h3 id="Parameters" name="Parameters">参数</h3>
<dl>
<dt><code>number</code></dt>
<dd>将被转换成证书的参数.</dd>
</dl>
<h2 id="Examples" name="Examples">示例</h2>
<h3 id="Example:_Using_toInteger" name="Example:_Using_toInteger">例子: 使用 <code>toInteger()方法</code></h3>
<pre><code  class="language-javascript">Number.toInteger(0.1);     // 0
Number.toInteger(1);       // 1
Number.toInteger(Math.PI); // 3
Number.toInteger(null);    // 0
</code></pre>
<h2 id="Specifications" name="Specifications">Specifications</h2>
<ul>
<li><code>Number.toInteger()</code> 是<span style="line-height: 19.0909080505371px;">ECMAScript 6 起草的一部分</span>, 但在2013-8-23的Draft Rev 17 中被移除 .</li>
</ul>
<h2 id="Browser_compatibility" name="Browser_compatibility">浏览器兼容性</h2>
<div><div class="blockIndicator warning"><strong><a class="external" href="https://github.com/mdn/browser-compat-data" rel="noopener">We're converting our compatibility data into a machine-readable JSON format</a></strong>.
            This compatibility table still uses the old format,
            because we haven't yet converted the data it contains.
            <strong><a class="new" href="/zh-CN/docs/MDN/Contribute/Structures/Compatibility_tables" rel="nofollow">Find out how you can help!</a></strong></div>
<div class="htab">
<a id="AutoCompatibilityTable" name="AutoCompatibilityTable"></a>
<ul>
<li class="selected"><a>Desktop</a></li>
<li><a>Mobile</a></li>
</ul>
</div></div>
<div id="compat-desktop">
<table class="compat-table">
<tbody>
<tr>
<th>Feature</th>
<th>Chrome</th>
<th>Firefox (Gecko)</th>
<th>Internet Explorer</th>
<th>Opera</th>
<th>Safari</th>
</tr>
<tr>
<td>Basic support</td>
<td><span style="color: #f00;">未实现</span></td>
<td>Firefox 16 to 32</td>
<td><span style="color: #f00;">未实现</span></td>
<td><span style="color: #f00;">未实现</span></td>
<td><span style="color: #f00;">未实现</span></td>
</tr>
</tbody>
</table>
</div>
<div id="compat-mobile">
<table class="compat-table">
<tbody>
<tr>
<th>Feature</th>
<th>Android</th>
<th>Chrome for Android</th>
<th>Firefox Mobile (Gecko)</th>
<th>IE Mobile</th>
<th>Opera Mobile</th>
<th>Safari Mobile</th>
</tr>
<tr>
<td>Basic support</td>
<td><span style="color: #f00;">未实现</span></td>
<td><span style="color: #f00;">未实现</span></td>
<td>Firefox 16 to 32</td>
<td><span style="color: #f00;">未实现</span></td>
<td><span style="color: #f00;">未实现</span></td>
<td><span style="color: #f00;">未实现</span></td>
</tr>
</tbody>
</table>
</div>
<h2 id="See_also" name="See_also">See also</h2>
<ul>
<li>归属于 <a href="Reference/Global_Objects/Number" title="JavaScript 的 Number 对象是经过封装的能让你处理数字值的对象。Number 对象由 Number() 构造器创建。"><code>Number</code></a> 对象.</li>
</ul>
</article>